package com.wtwd.device.controller;


import com.wtwd.device.constant.RespCode;
import com.wtwd.device.model.entity.LastLocationData;
import com.wtwd.device.model.entity.LocationData;
import com.wtwd.device.model.vo.ResultVO;
import com.wtwd.device.service.ILastLocationDataService;
import com.wtwd.device.service.ILocationDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author mjy
 * @since 2024-05-21
 */
@Api(tags = "轨迹模块")
@RestController
@RequestMapping("/location-data")
public class LocationDataController {


    @Resource
    private ILocationDataService locationDataService;

    /**
     * 根据设备id获取设备轨迹信息
     *
     * @param startTime
     * @param endTime
     * @return
     */
    @ApiOperation("获取设备轨迹")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "startTime", value = "开始时间 yyyyMMddHHmmss", required = true, dataType = "String"),
            @ApiImplicitParam(name = "endTime", value = "结束时间 yyyyMMddHHmmss", required = true, dataType = "String"),
            @ApiImplicitParam(name = "deviceId", value = "设备id", required = true, dataType = "long"),
    })
    @GetMapping("/getDeviceLocationByTime")
    public ResultVO<List<LocationData>> getDeviceLocationByTime(@RequestParam String startTime, @RequestParam String endTime,@RequestParam Long deviceId) {
        List<LocationData> data = locationDataService.getDeviceLocationByTime(deviceId,startTime,endTime);
        return ResultVO.success(RespCode.SUCCESS, data);
    }

}

